using System;
using Microsoft.SPOT;
using System.Text;

namespace OST.Shared.Extensions
{
    public static class StringExtensions
    {
        /// <summary>
        /// Indicates whether the specified string is null or an System.String.Empty
        ///     string.
        /// </summary>
        /// <param name="value2Check">The string to test</param>
        /// <returns>true if the value parameter is null or an empty string (""); otherwise, false</returns>
        public static bool IsNullOrEmpty(this String value2Check)
        {
            if (value2Check == null)
            {
                return true;
            }

            if (value2Check == String.Empty)
            {
                return true;
            }
            return false;
        }

        /// <summary>
        /// removes the specified character from given string
        /// </summary>
        /// <param name="baseString">given string</param>
        /// <param name="strings2Remove">strings to remove</param>
        /// <returns>cleared string</returns>
        public static string RemoveStrings(this string baseString, string[] strings2Remove)
        {
            var startOffset = 50;
            var currentCleanString = new StringBuilder(baseString);
            foreach (var removeString in strings2Remove)
            {
                var count = (currentCleanString.Length - 1) - startOffset;
                currentCleanString = currentCleanString.Replace(removeString, "", startOffset, count);
            }

            return currentCleanString.ToString();
        }
    }
}
